package com.fitness.fitness.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.fitness.fitness.modal.resource.entity.Equipment;
import com.fitness.fitness.modal.resource.params.EquipmentPageQueryParams;
import org.apache.ibatis.annotations.Select;

public interface EquipmentMapper extends BaseMapper<Equipment> {
    @Select("<script>select * from t_equipment e"
            + " <where>"
            + "<if test='queryParams.keywords != null and queryParams.keywords.trim() neq \"\"'>"
            + " AND (e.name like  CONCAT('%',#{queryParams.keywords},'%') or e.sn like CONCAT('%',#{queryParams.keywords},'%'))"
            + "</if>"
            + "<if test='queryParams.status != null'>"
            + " AND e.status = #{queryParams.status} "
            + "</if>"
            + "</where>"
            +"</script>")
    Page<Equipment> getEqupmentPage(Page<Equipment> page, EquipmentPageQueryParams queryParams);
}
